package com.wuyoucar.controller;

import com.wuyoucar.common.ResultBean;
import com.wuyoucar.service.PersionCenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

@RestController
@RequestMapping("/consumer")
public class BindCarController {

    @Autowired
    private PersionCenterService persionCenterService;

    @PostMapping("/carinfo/{vin}/{carnumber}/{cartype}/{firstchecktime}/{seatamount}/{userid}")
    public ResultBean insertCarinfo(@PathVariable("vin") String vin,
                                    @PathVariable("carnumber") String carnumber,
                                    @PathVariable("cartype") String cartype,
                                    @PathVariable("firstchecktime") String firstchecktime,
                                    @PathVariable("seatamount") int seatamount,
                                    @PathVariable("userid") int userid) throws ParseException{
        return persionCenterService.insertCarinfo(vin,carnumber,cartype,firstchecktime,seatamount,userid);
    }

    //根据用户id 查询用户是否绑定车辆
    @GetMapping("/checkbindcar/{userid}")
    public ResultBean selectAllCarById(@PathVariable("userid")Integer userid){
        return persionCenterService.selectAllCarById(userid);
    }

    //借除绑定
    @GetMapping("/unbunding/{vin}")
    public ResultBean unbunding(@PathVariable("vin")Integer vin){
        return persionCenterService.unbunding(vin);
    }
}
